<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header">
    <header class="header" style="border-bottom: none;">
        <!--<div class="header-left">-->
        <!--<div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png" /></div>-->
        <!--</div>-->
        <!-- <div class="header-right">
            <div  tapmode onclick="commonUrl('register')" class="nav-right">注册</div>
        </div> -->
    </header>
</div>

<section class="html_section pr30 pl30 login_section">
    <div class="line_center flex_center"><img class="logon_logo" src="../../icon/logo_login.png"/></div>
    <div class="line_center flex_center f32 mt20">大学情报局</div>
    <div class="line_center flex_center f26 c-999">助力你的大学生活</div>
    <div style="margin-top:0.5rem" class="f26">
        <div class="line_center"><input id="phone" class="login_input" placeholder="请输入您的手机号"/></div>
        <div class="line_center yzm_box">
            <input id="code" class="login_input" placeholder="请输入验证码"/>
            <div tapmode class="yzm">获取验证码</div>
        </div>
    </div>
    <div class="mt20 f22 c-666 lh48 clearfix"><span ischeck="2" class="radioIcon"></span>注册登录即代表同意<span class="c-primary" tapmode onclick="commonUrl('../member/xieyi')">《大学情报局用户协议》</span>和<span
            class="c-primary" tapmode onclick="commonUrl('../member/yinsizhengce')">《隐私政策》</span></div>
    <div tapmode class="btn1 mt60 f30" onclick="login()">登录</div>
    <div tapmode class="btn2 mt30 f30" onclick="commonUrl('login_pwd')">用账号密码登录</div>
    <div class="flex_end mt10">
        <div class="c-fff f22" tapmode>忘记密码?</div>
    </div>
    <div class="lines c-999 f22 threeLogin" style="display: none;"><span class="ml20 mr20">第三方快捷登录</span></div>
    <ul class="three threeLogin" style="display: none;">
        <li tapmode class="qq" id="qqLogin"><img src="../../icon/three-qq.png"/></li>
        <li tapmode class="wb" id="wbLogin"><img src="../../icon/three-wb.png"/></li>
        <li tapmode class="wx" id="wxLogin"><img src="../../icon/three-wx.png"/></li>
    </ul>
</section>

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/login.js"></script>
<script type="text/javascript">
    $(".radioIcon").click(function(){
        //1.选中 2未选中
        var ischeck =$(this).attr("ischeck");
        if(ischeck == 1){
            $(this).removeClass("radioOn");
            $(this).attr("ischeck","2");
        }else if(ischeck ==2){
            $(this).addClass("radioOn");
            $(this).attr("ischeck","1");
        }
    });
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        var token = $api.getStorage('token');
        var phone = $api.getStorage('phone');
        if(isDefine(phone)){
            $("#phone").val(phone)
        }

        api.addEventListener({
            name: 'closeCurrWinIndex'
        }, function (ret, err) {
            api.closeWin();
        });
        api.sendEvent({
            name: 'closeCurrWinLogin',
        });



        checkSystemType(function () {
            checked_three();
        },function () {

        });

        if(token){
            var userInfo = $api.getStorage('userInfo');
            console.log(jsonChange(userInfo));
            if (userInfo.status != 2) {
                individualUrl('../index/index');
            }
        }

        SystemCheckVersion()

    };

    //获取验证码
    $(".yzm").click(function () {
        hqyzm($("#phone").val(), function (ret) {
            var param = {tel: $("#phone").val(), type: 1};
            pop.loading();
            getAjax(Interface.set_sms, param, function (res) {
                console.log(JSON.stringify(res));
                ret();
                pop.close();
            }, function (ret, err) {

            })
        });
    })
    //提交 - 登录
    function login() {
        $(".login_input").blur();
        var param = {
            type: 1,
            tel: $("#phone").val(),
            code: $("#code").val(),
            device_id: api.deviceId
        };
        if (param.tel == "") {
            pop.notice('请输入您的手机号');
            return
        }
        if (param.code == "") {
            pop.notice('请输入验证码');
            return
        }
        var ischeck =$(".radioIcon").attr("ischeck");
        // alert(ischeck)
        if(Number(ischeck) !==1){
            pop.notice('请勾选大学情报局用户协议和隐私政策');
            return
        }
        pop.loading();
        getAjax(Interface.login, param, function (res) {
            console.log(res);
            $api.setStorage('phone', $("#phone").val());
            $api.setStorage('token', res.token);
            $api.setStorage('userInfo', res.data);
            if(isDefine(res.data.school_path)){
                $('#school_path').attr('src', ajaxUrl + res.data.school_path);
                $api.setStorage('schoolPath', ajaxUrl + res.data.school_path);
                $api.setStorage('schoolPath_status', 1);
                api.sendEvent({
                    name: 'schoolPathStatus',
                });


            }else {
                $('#school_path').attr('src', '../../icon/logo.png');
                $api.setStorage('schoolPath', '../../icon/logo.png');
                $api.setStorage('schoolPath_status', 2);
                api.sendEvent({
                    name: 'schoolPathStatus',
                });
            }
            $api.setStorage('newLogin', 1);
            pop.close();
            if (res.data.status == 2) {
                commonUrl('perfect');
                $("#code").val('');
            } else {
                individualUrl('../index/index');
                $("#code").val('');
            }

        }, function (ret, err) {
            pop.close();
            pop.notice(ret.msg);
        })
    }
    //微信
    $("#wxLogin").click(function(){
        wxLogin(function(ret){
            var p = {outher_id:ret.unionid,type:1}
            threeLogin(p);
        })
    })
    //Qq
    $("#qqLogin").click(function(){
        QQLogin(function(ret){
            var p = {outher_id:ret.openId,type:2}
            threeLogin(p);
        })
    })
    //微博
    $("#wbLogin").click(function(){
        WeiBoLogin(function(ret){
            var p = {outher_id:ret.userId,type:3}
            threeLogin(p);
        })
    })
    function threeLogin(p){
         getAjax(Interface.other_login,p,function(res){
            pop.close();
            if(res.token){
                $api.setStorage('token', res.token);
                $api.setStorage('userInfo', res.data);
                if(isDefine(res.data.school_path)){
                    $('#school_path').attr('src', ajaxUrl + res.data.school_path);
                    $api.setStorage('schoolPath', ajaxUrl + res.data.school_path);
                    $api.setStorage('schoolPath_status', 1);
                }else {
                    $('#school_path').attr('src', '../../icon/logo.png');
                    $api.setStorage('schoolPath', '../../icon/logo.png');
                    $api.setStorage('schoolPath_status', 2);
                }
                pop.close();
                if (res.data.status == 2) {
                    commonUrl('perfect');
                } else {
                    individualUrl('../index/index');
                }
            }else{
                commonUrl('bang_tel',p);
            }
        },function(res,err){
           
        })
    }


</script>
